package com.coocaa.typhoon.api.third.elasticsearch.repository;

import com.coocaa.typhoon.api.third.elasticsearch.model.UserFileDoc;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.elasticsearch.annotations.Query;
import org.springframework.data.elasticsearch.repository.ElasticsearchRepository;

import java.util.List;

/**
 * @author bijiahao
 * @date : 2025/10/22 09:13
 * @description
 */
public interface UserFileRepository extends ElasticsearchRepository<UserFileDoc, String> {
    // 根据用户ID查询
    List<UserFileDoc> findByUserId(String userId);

    // 根据文件类型分页
    Page<UserFileDoc> findByFileType(String fileType, Pageable pageable);

    // 自定义 DSL
    @Query("{\"bool\": {\"must\": [{\"match\": {\"filePath\": \"?0\"}}]}}")
    Page<UserFileDoc> searchInFilePath(String key, Pageable pageable);
}
